package table_host;

import android.os.Bundle;

import button.SwitchButton;
import button.TomPreference;
import tangyaxin.www.saoerweima.BaseAcitivity;
import tangyaxin.www.saoerweima.BaseFragment;
import tangyaxin.www.saoerweima.R;

/**
 * Created by Administrator on 2016/6/7.
 */
public class SettingActivity extends BaseAcitivity {
    private SwitchButton sound_switcher,vibrate_switcher;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.frament_setting);
        findview();
        initview();
    }

    @Override
    protected void findview() {
        sound_switcher= (SwitchButton) findViewById(R.id.sound_switcher);
        vibrate_switcher= (SwitchButton) findViewById(R.id.vibrate_switcher);
    }

    @Override
    protected void initview() {
    sound_switcher.setOnCheckChangeListener(onCheckChangeListener);
    vibrate_switcher.setOnCheckChangeListener(onCheckChangeListener);
    }
    private SwitchButton.OnCheckChangeListener onCheckChangeListener=new SwitchButton.OnCheckChangeListener() {
        @Override
        public void OnCheck(SwitchButton switchButton, boolean isChecked) {
            switch (switchButton.getId()){
                case R.id.sound_switcher:
                    TomPreference.getInstance(SettingActivity.this).setIsSoundOn(isChecked);
                    break;
                case R.id.vibrate_switcher:
                    TomPreference.getInstance(SettingActivity.this).setIsVibrateOn(isChecked);
                    break;
            }
        }
    };
}
